package com.niit.qcx.commAgePrice;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
public class commAPDriver {
    public static void main(String[] args) throws Exception {
        //1.创建驱动类
        Configuration conf = new Configuration();
        //2.声明Job对象
        Job job = Job.getInstance(conf);
        //3.设置mr程序运行的主类
        job.setJarByClass(commAPDriver.class);
        //4.指定当前job的Mapper和Reducer
        job.setMapperClass(commAPMapper.class);
        job.setReducerClass(commAPReducer.class);
        //5.指定Mapper输出的key和value的类型 (内部要用)
        job.setMapOutputKeyClass(Text.class);
        job.setMapOutputValueClass(commAPBean.class);
        //6.指定Reducer输出结果的key和value的类型 (内部要用)
        job.setOutputKeyClass(Text.class);
        job.setOutputValueClass(commAPBean.class);
        //7.指定本次作业的输入和输出路径
        FileInputFormat.setInputPaths(job, new Path("input/anjuke.txt"));
        FileOutputFormat.setOutputPath(job, new Path("output/qcx_out/commAP"));
        //采用waitForCompletion提交job，参数表示是否开启实时监视追踪作业的执行情况
        boolean resultFlag = job.waitForCompletion(true);
        //退出程序 和job结果进行绑定, 0是正常退出，1是异常退出
        System.exit(resultFlag ? 0: 1);
    }
}

